package cn.stormbirds.stpaylib;

import android.app.Activity;

import com.alipay.sdk.app.EnvUtils;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import cn.stormbirds.stpaylib.bean.OrderRequest;
import cn.stormbirds.stpaylib.handler.BasePayHandler;
import cn.stormbirds.stpaylib.utils.ThreadManager;
import okhttp3.OkHttpClient;

/**
 * Copyright (c) 小宝 @2019
 *
 * @ Package Name:    cn.stormbirds.stpaylib
 * @author         stormbirds
 * @ Email：          xbaojun@gmail.com
 * @ Created At：     2019/6/25 09:30
 * @ Description：
 */


public enum STPaySDK implements ISTPayService {
    /**
     * 单例模式获取支付SDK类
     */
    INSTANCE;

    protected static BasePayHandler mBasePayHandler;

    public static boolean isTest = false;
    public static boolean isPermissionSEPay = false;

    public static String toPayURL = "https://pay.snhanyue.top/topay";
    public static String appTransUrl = "https://gateway%s.95516.com/gateway/api/appTransReq.do";
    public static OkHttpClient mOkHttpClient = new OkHttpClient.Builder()
            .callTimeout(5, TimeUnit.SECONDS)
            .readTimeout(5, TimeUnit.SECONDS)
            .build();

    STPaySDK() {
    }

    public static void threadPoolUtils(Runnable runnable){
        ThreadManager.getThreadPool().exeute(runnable);
    }

    @Override
    public void pay(Activity activity, OrderRequest order, PayType payType, STPayCallback callback) {
        PaymentTask paymentTask = new PaymentTask(activity, payType, callback);
        paymentTask.execute(order);
    }
}
